<template>
  <div class="icons">
      <swiper :options="swiperOption">
          <swiper-slide v-for="(page,index) in pages" :key="index">
            <ul>
                <li class="icon" v-for="item in page" :key="item.id">
                    <img class="icon-img" :src="item.imgUrl">
                    <p class="icon-des">{{item.desc}}</p>
                </li>
            </ul>
          </swiper-slide>
      </swiper>
  </div>
</template>
<script>
export default {
  name: "HomeIcons",
  props: ["list"],
  data() {
    return {
        swiperOption: {
            autoplay: false
        }
    };
  },
  computed: {
    pages() {
      const pages = [];
      this.list.forEach((item, index) => {
        const page = Math.floor(index / 8);
        if (!pages[page]) {
          pages[page] = [];
        }
        pages[page].push(item);
      });
      return pages;
    }
  }
};
</script>
<style lang="stylus" scoped>
@import '~styles/variables.styl';
@import '~styles/mixins.styl';

.icons
  height: 0;
  padding-bottom: 50%;
  overflow: hidden;
  margin-top: .1rem

  .icon 
    float: left;
    width: 25%;
    height: 0;
    padding-bottom: 25%;

    .icon-img 
      width: 80%;
      margin-left: 50%;
      transform: translate(-50%);
    

    .icon-des 
      text-align: center;
      color: $darKTextColor;
      eclipsis();

</style>